package com.ruoyi.student.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.student.mapper.StuZxjMapper;
import com.ruoyi.student.domain.StuZxj;
import com.ruoyi.student.service.IStuZxjService;

/**
 * 助学金Service业务层处理
 *
 * @author 钟彧
 * @date 2022-07-04
 */
@Service
public class StuZxjServiceImpl implements IStuZxjService
{
    @Autowired
    private StuZxjMapper stuZxjMapper;

    /**
     * 查询助学金
     *
     * @param zxjId 助学金主键
     * @return 助学金
     */
    @Override
    public StuZxj selectStuZxjByZxjId(Long zxjId)
    {
        return stuZxjMapper.selectStuZxjByZxjId(zxjId);
    }

    /**
     * 查询助学金
     *
     * @param zxjId 助学金主键
     * @return 助学金
     */
    @Override
    public StuZxj selectStuZxjByZxjIdAndUid(Long zxjId,Long userId)
    {
        return stuZxjMapper.selectStuZxjByZxjIdAndUid(zxjId,userId);
    }

    /**
     * 教师获取单条助学金
     * @param zxjId 助学金主键
     * @return
     */
    @Override
    public StuZxj queryStuZxj(StuZxj stuZxj) {
        return stuZxjMapper.queryStuZxj(stuZxj);
    }

    /**
     * 查询助学金列表
     *
     * @param stuZxj 助学金
     * @return 助学金
     */
    @Override
    public List<StuZxj> selectStuZxjList(StuZxj stuZxj)
    {
        return stuZxjMapper.selectStuZxjList(stuZxj);
    }


    /**
     * 查询需审批助学金列表（过滤）
     *
     * @param stuZxj 助学金
     * @return 助学金
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "s")
    public List<StuZxj> selectStuZxjListByTeacher(StuZxj stuZxj)
    {
        return stuZxjMapper.selectStuZxjListByTeacher(stuZxj);
    }

    /**
     * 新增助学金
     *
     * @param stuZxj 助学金
     * @return 结果
     */
    @Override
    public int insertStuZxj(StuZxj stuZxj)
    {
        stuZxj.setCreateBy(stuZxj.getUserName());
        stuZxj.setCreateTime(DateUtils.getNowDate());
        return stuZxjMapper.insertStuZxj(stuZxj);
    }

    /**
     * 修改助学金
     *
     * @param stuZxj 助学金
     * @return 结果
     */
    @Override
    public int updateStuZxj(StuZxj stuZxj)
    {
        stuZxj.setUpdateTime(DateUtils.getNowDate());

        return stuZxjMapper.updateStuZxj(stuZxj);
    }

    /**
     * 批量删除助学金
     *
     * @param zxjIds 需要删除的助学金主键
     * @return 结果
     */
    @Override
    public int deleteStuZxjByZxjIds(Long[] zxjIds)
    {
        return stuZxjMapper.deleteStuZxjByZxjIds(zxjIds);
    }

    /**
     * 删除助学金信息
     *
     * @param zxjId 助学金主键
     * @return 结果
     */
    @Override
    public int deleteStuZxjByZxjId(Long zxjId)
    {
        return stuZxjMapper.deleteStuZxjByZxjId(zxjId);
    }

    /**
     * 删除本人助学金信息
     * @param zxjIds
     * @param userId
     * @return
     */
    @Override
    public int deleteStuZxjByZxjIdsAndUid(Long[] zxjIds, Long userId) {
        return stuZxjMapper.deleteStuZxjByZxjIdsAndUid(zxjIds,userId);
    }

    /**
     * 当前已提交助学金条数
     * @param userId
     * @return
     */
    @Override
    public int getYTJ(Long userId) {
        return stuZxjMapper.getYTJ(userId);
    }

    /**
     * 当前审核中助学金条数
     * @param userId
     * @return
     */
    @Override
    public int getSHZ(Long userId) {
        return stuZxjMapper.getSHZ(userId);
    }

    /**
     * 当前已通过助学金条数
     * @param userId
     * @return
     */
    @Override
    public int getYTG(Long userId) {
        return stuZxjMapper.getYTG(userId);
    }

    @Override
    public int getWTG(Long userId) {
        return stuZxjMapper.getWTG(userId);
    }
}
